package com.heima.behavior.controller.v1;


import com.heima.behavior.service.*;
import com.heima.model.behavior.dtos.*;
import com.heima.model.common.dtos.ResponseResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Api(value = "文章行为API接口",tags = "文章行为API接口")
@RestController
@RequestMapping("/api/v1")
public class BehaviorController {

    //注入点赞行为
    @Autowired
    ApLikesBehaviorService apLikesBehaviorService;

    //注入阅读行为
    @Autowired
    ApReadBehaviorService apReadBehaviorService;

    //注入不喜欢行为
    @Autowired
    ApUnlikeBehaviorService apUnlikeBehaviorService;

    //文章行为
    @Autowired
    ApArticleBehaviorService apArticleBehaviorService;

    //收藏行为
    @Autowired
    ApCollectionBehaviorService apCollectionBehaviorService;

    @ApiOperation("用户或游客点赞或取消点赞行为")
    @PostMapping("likes_behavior")
    public ResponseResult like(@RequestBody @Validated LikesBehaviorDTO dto){
        return apLikesBehaviorService.like(dto);
    }

    @ApiOperation("用户或游客阅读行为")
    @PostMapping("read_behavior")
    public ResponseResult readBehavior(@RequestBody @Validated ReadBehaviorDTO dto){
        return apReadBehaviorService.readBehavior(dto);
    }


    @ApiOperation("用户或游客不喜欢行为")
    @PostMapping("un_likes_behavior")
    public ResponseResult unlikeBehavior(@RequestBody @Validated UnLikesBehaviorDTO dto){
        return apUnlikeBehaviorService.unlikeBehavior(dto);
    }

    @ApiOperation("用户或游客保存或取消 收藏行为")
    @PostMapping("collection_behavior")
    public ResponseResult collectBehavior(@RequestBody @Validated CollectionBehaviorDTO dto){
        return apCollectionBehaviorService.collectBehavior(dto);
    }


    @ApiOperation("文章行为API")
    @PostMapping("article/load_article_behavior")
    public ResponseResult loadArticleBehavior(@RequestBody @Validated ArticleBehaviorDTO dto){
        return apArticleBehaviorService.loadArticleBehavior(dto);
    }

}
